﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    Async="true" CodeFile="trueyou-call-me.aspx.cs" Inherits="car_insurance_trueyou_call_me" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpHeader" runat="Server">
    <div class="main-bg">
        <div class="radius-box">
            <div class="general-col-left" id="divTrueYouMessage" runat="server">
                <asp:Image ID="imgReachLimit" runat="server" ImageUrl="<%$ Resources:ImageResource,ImgReachLimitUrl%>"
                        Width="399" Height="393" alt="" />
            </div>
            <div class="general-col-left" id="divTrueYouCallMe" runat="server">
                <asp:UpdatePanel ID="updatepanel" runat="server">
                    <ContentTemplate>
                        <div class="main-title-heading-label">
                            <h1>
                                <%=GetGlobalResourceObject("General", "CarNotfoundLetusCallBack")%></h1>
                        </div>
                        <div style="width: 440px;">
                            <asp:Label ID="lblMessage" ForeColor="Red" runat="server"></asp:Label>
                            <asp:ValidationSummary ID="vsCustomer" runat="server" ValidationGroup="callme" ShowSummary="True"
                                HeaderText="<%$ Resources:General,RequiredValidation%>" CssClass="error-msg"
                                Height="45px" />
                        </div>
                        <br />
                        <div>
                            <div class="form-column">
                                <span style="color: #FF0004">*</span><%=GetGlobalResourceObject ("General","PromoCode") %>
                            </div>
                            <div class="form-row">
                                <asp:TextBox ID="txtPromoCode" runat="server" CssClass="cb-fields" MaxLength="10"></asp:TextBox>
                                <cc1:TextBoxWatermarkExtender ID="tbwPromoCode" runat="server" TargetControlID="txtPromoCode"
                                    WatermarkCssClass="cb-fields" WatermarkText="<%$Resources:General,EnterPromoCode%>">
                                </cc1:TextBoxWatermarkExtender>
                                <asp:RequiredFieldValidator ID="rfvPromoCode" runat="server" Text="" CssClass="validationError"
                                    ValidationGroup="callme" ErrorMessage="" ControlToValidate="txtPromoCode" Display="Dynamic"></asp:RequiredFieldValidator>
                                <div style="display: none">
                                    <asp:TextBox ID="txtPromoCodeValid" Text="Valid" runat="server"></asp:TextBox>
                                    <asp:CustomValidator CssClass="validationError" ControlToValidate="txtPromoCodeValid"
                                        ValidationGroup="callme" ID="csvPromoCodeValid" ClientValidationFunction="CheckPromoCodeValid"
                                        OnServerValidate="CheckPromoCodeValid" runat="server" ErrorMessage="" Text=""></asp:CustomValidator>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="form-column">
                                <span style="color: #FF0004">*</span><%=GetGlobalResourceObject ("CarInsurance","CallMeAt") %>
                            </div>
                            <div class="form-row">
                                <asp:DropDownList CssClass="input-fields-dropdown" runat="server" ID="ddlCallMeTime">
                                    <asp:ListItem Value="-1" Text="<%$Resources:CarInsurance,Select %>" />
                                    <asp:ListItem Value="1" Text="<%$Resources:CarInsurance,CallMeMorning %>" />
                                    <asp:ListItem Value="2" Text="<%$Resources:CarInsurance,CallMeAfternoon %>" />
                                    <asp:ListItem Value="3" Text="<%$Resources:CarInsurance,CallMeEvening %>" />
                                    <asp:ListItem Value="4" Text="<%$Resources:CarInsurance,CallMeAnytime %>" />
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvCallMeTime" runat="server" CssClass="validationError"
                                    ValidationGroup="callme" ErrorMessage="" Text="" InitialValue="-1" ControlToValidate="ddlCallMeTime"></asp:RequiredFieldValidator>
                            </div>
                        </div>
                        <div id="divButtonWithCookies">
                            <div class="form-row-full">
                                <asp:CheckBox ID="checkIsAgreementXvaues" runat="server" Checked="true" onclick="CheckedChanged();" />
                                <asp:Label ID="lblAgreementXvaues" runat="server" Text="<%$ Resources:General,Agreement%>"
                                    CssClass="check-agree-text"></asp:Label>
                                <asp:RequiredFieldValidator ID="rfvIsAcceptXvaues" runat="server" ControlToValidate="txtIsAcceptXvaues"
                                    CssClass="validationError" Display="Dynamic" ErrorMessage="" ValidationGroup="callme"></asp:RequiredFieldValidator>
                                <div style="display: none;">
                                    <asp:TextBox ID="txtIsAcceptXvaues" runat="server"></asp:TextBox>
                                </div>
                            </div>
                            <div class="form-row-full">
                                <asp:Button ID="btnSubmitXvaues" ValidationGroup="callme" Text="<%$ Resources:General,Submit%>"
                                    runat="server" CssClass="action-button" Width="150" OnClick="btnSubmit_Click"
                                    OnClientClick="LoadValidationErrorCss();CheckedChanged();if (Page_ClientValidate('callme')){this.removeAttribute('onmouseout');this.removeAttribute('onmouseup');this.className = 'action-button-processing';}" /><br />
                            </div>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <div class="form-row-full" id="divEditOption">
                    <div class="heading-sub-title" style="width: 300px; float: left;">
                        <%=GetGlobalResourceObject("General", "YourDetails")%></div>
                    <div style="float: right; width: 140px; text-align: right; padding-top: 20px;">
                        <a href="" class="general-links" style="text-align: right;" onclick="EnableEditDetails();return false;">
                            <img src="/images/edit.png" width="16" height="16" alt="แก้ไขข้อมูลการซื้อประกัน" /><%=GetGlobalResourceObject("General", "Edit")%></a>
                    </div>
                </div>
                <div>
                    <div class="form-column">
                        <span style="color: #FF0004">*</span><%=GetGlobalResourceObject("CarInsurance", "FullName")%></div>
                    <div class="form-row">
                        <asp:TextBox ID="txtName" runat="server" MaxLength="70" CssClass="input-fields"></asp:TextBox>
                        <cc1:TextBoxWatermarkExtender ID="tbwName" runat="server" TargetControlID="txtName"
                            WatermarkCssClass="input-fields" WatermarkText="<%$Resources:General,EnterName%>">
                        </cc1:TextBoxWatermarkExtender>
                        <asp:RequiredFieldValidator ID="rfvName" runat="server" ControlToValidate="txtName"
                            Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="callme" CssClass="validationError"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="revName" Text="" CssClass="validationError" runat="server"
                            ValidationGroup="callme" ErrorMessage="" ControlToValidate="txtName" ValidationExpression="^([\u0000-\uDFFF']{1,50})$|^([a-zA-Z''-'\s]{1,50})$"
                            Display="Dynamic"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div>
                    <div class="form-column">
                        <span style="color: #FF0004">*</span><%=GetGlobalResourceObject("CarInsurance", "EmailAddress")%></div>
                    <div class="form-row">
                        <asp:TextBox ID="txtEmail" runat="server" MaxLength="70" CssClass="input-fields"></asp:TextBox>
                        <a class="tooltips2" style="padding-top: 5px;">
                            <img src="/images/lock.png" alt="ผู้รับผลประโยชน์" height="25" width="25" />
                        </a>
                        <cc1:TextBoxWatermarkExtender ID="tbwEmail" runat="server" TargetControlID="txtEmail"
                            WatermarkCssClass="input-fields" WatermarkText="<%$Resources:General,EnterEmail%>">
                        </cc1:TextBoxWatermarkExtender>
                        <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="txtEmail"
                            CssClass="validationError" Display="Dynamic" ErrorMessage="" Text="" ValidationGroup="callme"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="revEmail" Text="" CssClass="validationError"
                            runat="server" ValidationGroup="callme" ErrorMessage="" ControlToValidate="txtEmail"
                            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div>
                    <div class="form-column">
                        <span style="color: #FF0004">*</span><%=GetGlobalResourceObject("CarInsurance", "MobileNo")%></div>
                    <div class="form-row">
                        <asp:TextBox runat="server" ID="txtMobile" CssClass="input-fields" MaxLength="10"></asp:TextBox>
                        <a class="tooltips2" style="padding-top: 5px;">
                            <img src="/images/lock.png" alt="ระบุชื่อผู้ขับ" height="25" width="25" />
                        </a>
                        <cc1:TextBoxWatermarkExtender ID="tbwMobile" runat="server" TargetControlID="txtMobile"
                            WatermarkCssClass="input-fields" WatermarkText="<%$Resources:General,MobileExample%>">
                        </cc1:TextBoxWatermarkExtender>
                        <asp:RequiredFieldValidator ID="rfvMobile" runat="server" ControlToValidate="txtMobile"
                            CssClass="validationError" Display="Dynamic" ErrorMessage="" ValidationGroup="callme"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="revMobile" runat="server" ControlToValidate="txtMobile"
                            CssClass="validationError" ErrorMessage="" ValidationExpression="0[5-9]\d{8}"
                            ValidationGroup="callme"></asp:RegularExpressionValidator>
                    </div>
                </div>
                <div id="divButtonNoCookies">
                    <div class="form-row-full" id="divAgreement">
                        <asp:CheckBox ID="checkIsAgreement" runat="server" Checked="true" onclick="CheckedChanged();" />
                        <asp:Label ID="lblAgreement" runat="server" Text="<%$ Resources:General,Agreement%>"
                            CssClass="check-agree-text"></asp:Label>
                        <asp:RequiredFieldValidator ID="rfvIsAccept" runat="server" ControlToValidate="txtIsAccept"
                            CssClass="validationError" Display="Dynamic" ErrorMessage="" ValidationGroup="callme"></asp:RequiredFieldValidator>
                        <div style="display: none;">
                            <asp:TextBox ID="txtIsAccept" runat="server"></asp:TextBox>
                        </div>
                    </div>
                    <div class="form-row-full">
                        <asp:Button ID="btnSubmit" ValidationGroup="callme" Text="<%$ Resources:General,Submit%>"
                            runat="server" CssClass="action-button" Width="150" OnClick="btnSubmit_Click"
                            OnClientClick="LoadValidationErrorCss();CheckedChanged();if (Page_ClientValidate('callme')){this.removeAttribute('onmouseout');this.removeAttribute('onmouseup');this.className = 'action-button-processing';}" /><br />
                    </div>
                </div>
            </div>
            <div class="general-col-right top20" style="margin-top: -50px;">
                <img id="imgChar" runat="server" src="/images/call-chac.png" width="350" height="350"
                    alt="โทรแจ้งข้อมูลประกันรถยนต์ฟรี" /></div>
            <asp:HiddenField runat="server" ID="hdnIsPromo" Value="0" />
        </div>
    </div>

    <script type="text/javascript">
        $(document).ready(function() {

            if (readCookie("GGQuote") == null) {
                //ShowHideDiv('divAgreement', true);
                ShowHideDiv('divButtonNoCookies', true);
                ShowHideDiv('divButtonWithCookies', false);
                ShowHideDiv('divEditOption', false);
                document.getElementById("<%=txtName.ClientID%>").className = "input-fields";
                document.getElementById("<%=txtMobile.ClientID%>").className = "input-fields";
                document.getElementById("<%=txtEmail.ClientID%>").className = "input-fields";
            }
            else {
                //ShowHideDiv('divAgreement', false);
                ShowHideDiv('divButtonNoCookies', false);
                ShowHideDiv('divButtonWithCookies', true);
                ShowHideDiv('divEditOption', true);
                document.getElementById("<%=txtName.ClientID%>").className = "input-fields-disable";
                document.getElementById("<%=txtMobile.ClientID%>").className = "input-fields-disable";
                document.getElementById("<%=txtEmail.ClientID%>").className = "input-fields-disable";
                document.getElementById("<%=txtName.ClientID%>").disabled = true;
                document.getElementById("<%=txtMobile.ClientID%>").disabled = true;
                document.getElementById("<%=txtEmail.ClientID%>").disabled = true;
            }
        });
        function readCookie(name) {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
            }
            return null;
        }

        function EnableEditDetails() {
            document.getElementById("<%=txtName.ClientID%>").disabled = false;
            document.getElementById("<%=txtMobile.ClientID%>").disabled = false;
            document.getElementById("<%=txtEmail.ClientID%>").disabled = false;

            document.getElementById("<%=txtName.ClientID%>").className = "input-fields";
            document.getElementById("<%=txtMobile.ClientID%>").className = "input-fields";
            document.getElementById("<%=txtEmail.ClientID%>").className = "input-fields";
        }

        function ShowHideDiv(diveName, varOnOff) {
            document.getElementById(diveName).style.display = varOnOff == true ? '' : 'none';
        }

        function CheckedChanged() {
            if (readCookie("GGQuote") == null) {
                var ctrlTxt = document.getElementById('<%=txtIsAccept.ClientID %>');
                var ctrlAgree = document.getElementById('<%=checkIsAgreement.ClientID %>');
                var lblAgree = document.getElementById('<%=lblAgreement.ClientID %>');
                var ctrlAgreeXvaues = document.getElementById('<%=checkIsAgreementXvaues.ClientID %>');
                var ctrlTxtXvaues = document.getElementById('<%=txtIsAcceptXvaues.ClientID %>');
                ctrlAgreeXvaues.checked = true;
                ctrlTxtXvaues.value = '1';
                ctrlTxt.value = '1';
                lblAgree.setAttribute("class", "check-agree-text");
                if (ctrlAgree.checked == false) {
                    ctrlTxt.value = '';
                    lblAgree.setAttribute("class", "check-agree-text validationError");
                }
            }
            else {
                var ctrlTxt = document.getElementById('<%=txtIsAcceptXvaues.ClientID %>');
                var ctrlAgree = document.getElementById('<%=checkIsAgreementXvaues.ClientID %>');
                var lblAgree = document.getElementById('<%=lblAgreementXvaues.ClientID %>');
                var ctrlAgreeOriginal = document.getElementById('<%=checkIsAgreement.ClientID %>');
                var ctrlTxtXvaues = document.getElementById('<%=txtIsAccept.ClientID %>');
                ctrlTxt.value = '1';
                ctrlTxtXvaues.value = '1';
                ctrlAgreeOriginal.checked = true;
                lblAgree.setAttribute("class", "check-agree-text");
                if (ctrlAgree.checked == false) {
                    ctrlTxt.value = '';
                    ctrlAgreeOriginal.checked = false;
                    lblAgree.setAttribute("class", "check-agree-text validationError");
                }
            }
        }

        function CheckPromoCodeValid(source, arguments) {
            var ctrlpromocode = document.getElementById('<%=txtPromoCode.ClientID%>');

            var promocode = ctrlpromocode.value;
            var result = true;
            if (promocode == 'gg999999' || promocode == 'GG999999') {
                result = true;
            }
            else {
                result = false;
            }

            if (result == false) {
                ctrlpromocode.style.border = 'Solid 1px #f00';
            }
            else {
                ctrlpromocode.style.border = '';
            }
            arguments.IsValid = result;
        }
    </script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cpBody" runat="Server">
</asp:Content>
